<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/echarts.js"></script>
</head>
<style>
    .cont_box{
        float: left;
        width: 800px;
        height: 650px;

    }
    .box {
        position: relative;
        border-radius: 3px;
        background: #ffffff;
        border-top: 3px solid #3c8dbc;
        padding: 10px;
        margin-bottom: 20px;
        width: 100%;
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
        overflow:hidden;
    }
</style>
<body class="hold-transition">

<div id="app">
    <div class="content-header">
        <h1>统计分析<small>会员人群占比</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>统计分析</el-breadcrumb-item>
            <el-breadcrumb-item>会员人群占比</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart1" class="cont_box" ></div>
        <div id="chart2" class="cont_box" ></div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart1 = echarts.init(document.getElementById('chart1'));
    var myChart = echarts.init(document.getElementById('chart2'));
    // 使用刚指定的配置项和数据显示图表。
    //myChart.setOption(option);
/*查询会员性别*/
    axios.get("/report/getCategory.do").then((res) => {
        if (res.data.flag) {
            myChart1.setOption({
                title: {
                    text: '会员性别占比',
                    subtext: '',
                    x: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b}: {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    left: 10,
                    data: ['男性会员', '女性会员']
                },
                series: [
                    {
                        name: '访问来源',
                        type: 'pie',
                        radius: ['50%', '70%'],
                        avoidLabelOverlap: false,
                        label: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            label: {
                                show: true,
                                fontSize: '30',
                                fontWeight: 'bold'
                            }
                        },
                        labelLine: {
                            show: false
                        },
                        data: [
                            {value: res.data.data.man, name: '男性会员'},
                            {value: res.data.data.woman, name: '女性会员'}
                        ]
                    }
                ]

            });
        } else {
            alert(res.data.message);
        }
    });
   // 查询会员年龄段
    axios.get("/report/getageCategory.do").then((res) => {
        if (res.data.flag) {
            myChart.setOption({
                title: {
                    text: '会员年龄段占比',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b} : {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                    data: ['0-18岁', '18-30岁','30-45岁','45岁以上'],
                },
                series: [
                    {
                        name: '年龄段',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '60%'],
                        data: [
                            {value: res.data.data.juvenile, name: '0-18岁'},
                            {value: res.data.data.youth, name: '18-30岁'},
                            {value: res.data.data.midlife, name: '30-45岁'},
                            {value: res.data.data.senium, name: '45岁以上'}
                        ],
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            })
        } else {
            alert(res.data.message);
        }
    });
</script>
</html>
